package com.stars.dao.mapper.system;

import com.stars.entity.ListPage;
import com.stars.entity.dto.sys.SystemPermissionDTO;
import com.stars.entity.sys.SystemPermission;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface SystemPermissionMapper extends Mapper<SystemPermission> {
    /**
     * 根据角色id查询该角色拥有的资源列表
     * @param dto 查询条件
     * @return
     * @throws Exception
     */
     List<SystemPermissionDTO> findByRoleId(@Param("entity") SystemPermissionDTO dto) throws Exception;

    /**
     * 用户拥有的资源
     * @param dto
     * @return
     * @throws Exception
     */
     List<SystemPermissionDTO> findPermissionByUserId(@Param("entity") SystemPermissionDTO dto) throws Exception;

    /**
     * 组织拥有的资源
     * @param dto
     * @return
     * @throws Exception
     */
     List<SystemPermissionDTO> findPermissionByOrgId(@Param("entity") SystemPermissionDTO dto) throws Exception;


     List<SystemPermissionDTO> findByRoleIdAndPerType(@Param("roleId") String roleId, @Param("perType") String perType) throws Exception;
     List<SystemPermissionDTO> findByPerType(@Param("perType") String perType) throws Exception;
    /**
     * 根据资源id查询子菜单
     * @param pid 资源id
     * @return 子菜单
     * @throws Exception
     */
     List<SystemPermissionDTO> findChildMenusByPid(@Param("pid") String pid) throws Exception;
    /**
     * 根据资源id查询子菜单
     * @param pid 资源id
     * @return 子菜单
     * @throws Exception
     */
     List<SystemPermissionDTO> findByPid(@Param("pid") String pid) throws Exception;
    /**
     * 根据资源id查询子菜单
     * @param systemPermissionDTOlist 资源
     * @return 菜单树
     * @throws Exception
     */
     List<SystemPermissionDTO> findAllMenus(@Param("list")List<SystemPermissionDTO> systemPermissionDTOlist) throws Exception;

    List<SystemPermissionDTO> findByPerName(@Param("entity") SystemPermissionDTO dto) throws Exception;
    /**
     * 根据资源id查询子菜单
     * @param systemPermissionlist 资源
     * @return 菜单树
     * @throws Exception
     */
    List<SystemPermissionDTO> findAllMenusByEntity(@Param("list")List<SystemPermissionDTO> systemPermissionlist) throws Exception;

    /**
     * 根据角色id查询
     * @param dtoList
     * @return
     * @throws Exception
     */
    List<SystemPermissionDTO> findAllMenusByRoleId(@Param("list")List<SystemPermissionDTO> dtoList,@Param("roleId") String roleId) throws Exception;

    /**
     * 根据用户id查询资源树形
     * @param dtoList 资源查询条件
     * @param userId 用户id
     * @return
     * @throws Exception
     */
    List<SystemPermissionDTO> findTreePermissionListByUserId(@Param("list")List<SystemPermissionDTO> dtoList,@Param("userId") String userId) throws Exception;

    /**
     * 根据用户组织查询资源树形
     * @param dtoList 资源查询条件
     * @param orgId 组织id
     * @return
     * @throws Exception
     */
    List<SystemPermissionDTO> findTreePermissionListByOrgId(@Param("list")List<SystemPermissionDTO> dtoList,@Param("orgId") String orgId) throws Exception;


     List<SystemPermissionDTO> findChildMenusByPidAndRoleId(@Param("pid") String pid, @Param("roleId") String roleId) throws Exception;
    /**
     *
     * @description 分页
     * @author dj
     * @date
     * @version 1.0.0
     */
     List<SystemPermissionDTO> findByPage(ListPage listPage) throws Exception;


}